/**
* Created by wl
* 项目管理>持有中-详情页-项目详情-项目管理人员信息
*/
<template>
    <div class="ca-box ca-m-t-28 ca-p-20">
        <div v-if="!showEdit">
            <div class="ca-title">
                <h3>项目管理人员</h3>
                <el-button type="text" class="ca-edit-btn el-icon-edit ca-m-r-10 edit-btn" @click="editInfo" :disabled="!isAuthIndexSee">编辑</el-button>
            </div>
            <table class="ca-table ca-m-t-15">
                <tr>
                    <th v-for="row in managerData" :key='row.userid' width="250px">{{row.name}}</th>
                </tr>
                <tr>
                    <td v-for="(item, index) in itemHoldManagerEntitys" :key="index">{{item.userId}}</td>
                </tr>
            </table>
        </div>
        <csProjectManager v-else :showBtn="true" @close="close" @save="save"></csProjectManager>
    </div>
</template>
<script type="text/ecmascript-6">
    import {api} from '../../api';
    import {STATUS_HTTP_SUCCESS, apiHttp} from '__service/csHttp';
    import { addRemind, isNoAuth} from '__service/utils';
    export default {
        data() {
            return {
                isAuthIndexSee: isNoAuth('持有中项目-项目详情-编辑'),
                showEdit: false,
                managerData: [{
                    name: '外派董事',
                    userid: 1
                },{
                    name: '外派监事',
                    userid: 2
                },{
                    name: '外派高管',
                    userid: 3
                },{
                    name: '外派高管职位',
                    userid: 4
                }],
                itemHoldManagerEntitys: [],
                value: '',
            }
        },
        watch: {
        },
        props: {},
        mounted() {
            this.getInfo()
        },
        methods: {
            close() {
                this.showEdit = false
            },
            async save() {
                this.showEdit = false
                await this.getInfo();
                // 添加小红点
                await addRemind({
                    dataId: this.$route.params.itemId, // 业务id
                    dataTab: 0, // tab页顺序 head 也为0 新建为'-1'
                    dataType: 2, // 1拟投资项目,2已投资项目,3母基金,4拟设立基金,5已设立基金,6客户,7潜在项目
                });
                // 根据第三方组件来调用 父组件中定义的方法 重新获取小红点
                this.$root.Dot.$emit('getDotList');
                // 添加小红点 end
            },
            editInfo() {
                this.showEdit = true
            },
            getInfo() {
                apiHttp(api.CHECK_MANAGER, {itemId: this.$route.params.itemId}).then(ret => {
                    if (ret.resCode === STATUS_HTTP_SUCCESS) {
                        this.itemHoldManagerEntitys = []
                        for (var i = 2; i < 6; i++) {
                            this.itemHoldManagerEntitys.push({
                                id: null, //id
                                itemId: null, //项目ID
                                userId: '', //管理人员 有可能存 人名
                                userType: Number(this.$store.state.user.dictionaryMap.holdManagerType[i].id) //管理人员类型-外派高管
                            })
                        }
                        if (ret.data.itemHoldManagerEntitys.length > 0) {
                            ret.data.itemHoldManagerEntitys.map((item) => {
                                this.itemHoldManagerEntitys.map((val,ind) => {
                                    if (item.userType === val.userType) {
                                        this.itemHoldManagerEntitys[ind] = item
                                    }
                                })
                            })
                        }
                    }
                })
            },
        },
        components: {
            csProjectManager: require('./edit'),
        },
    }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.edit-btn {
    float: right;
    cursor: pointer;
}
.el-wrap {
    word-wrap:break-word;
}
</style>